package net.knightwatch.kwtools.database; 

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class PotentialTable {
	// Class Information
		private static final String TAG = "PotentialTable";
		// Database Table
		public static final String TABLE_POTENTIAL = "Potentials";
		public static final String COLUMN_ID = "_id";
		public static final String COLUMN_BUILDING_ID = "buildingId";
		public static final String COLUMN_CUSTOMER_ID = "customerId";
		public static final String COLUMN_NAME = "name";
		public static final String COLUMN_COMPLETED = "completed";
		public static final String COLUMN_PROJECTED_START = "projectedStart";
		public static final String COLUMN_CREATED = "created";
		public static final String COLUMN_SCOPE_OF_WORK = "scopeOfWork";
		// Database Creation SQL Statement
		private static final String DATABASE_CREATE = "create table " 
				+ TABLE_POTENTIAL
				+ "("
				+ COLUMN_ID + " integer primary key autoincrement, "
				+ COLUMN_BUILDING_ID + " integer not null,"
				+ COLUMN_CUSTOMER_ID + " integer not null,"
				+ COLUMN_NAME + " text not null,"
				+ COLUMN_COMPLETED + " boolean,"
				+ COLUMN_PROJECTED_START + " datetime,"
				+ COLUMN_CREATED + " datetime,"
				+ COLUMN_SCOPE_OF_WORK + " text"
				+ ");";
		
		public static void onCreate(SQLiteDatabase database) {
			Log.i(TAG, DATABASE_CREATE);
			try {
			database.execSQL(DATABASE_CREATE);
			} catch (Exception e){
				Log.v(TAG, e.toString());
			}
		}
		public static void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion){
			if(oldVersion < 2){
				// First update alter table to add fields
			}
			if(oldVersion < 3){
				// Do Second Update alter table to add extra fields
			}
		}
}
